{extend name="$member_style_layout" /}

{block name="title"}短消息{/block}
{block name="content"}
{include file="msg/menu" /}

<link rel="stylesheet" href="__STATIC__/layui/css/template.css" media="all">
<style type="text/css">
.layadmin-message-fluid{
	padding:0;
}
.layui-col-md12{
	background:#000;
	padding:10px;
	border-bottom:1px solid #eee;
}
.media-body{
	padding-bottom:15px;
	border-bottom:1px solid #eee;
}
.msg_title{color:#03A9F4;font-size:16px;}
</style>
<div class="layui-fluid layadmin-message-fluid">
  <div class="layui-row">
    <div class="layui-col-md12" style="padding-bottom:0px;">
      <div class="layui-form" style="padding:10px">
        <div class="layui-form-item layui-form-text">
          <div class="layui-input-block">
            <textarea name="desc"  placeholder="请输入内容" class="layui-textarea msgcontent"></textarea>
          </div>
        </div>

         <div class="layui-form-item" style="overflow: hidden;">
          <div class="layui-input-block layui-input-right">
            <button class="layui-btn" onclick="postmsg()">发表</button>
          </div>          
        </div>
      </div>
    </div>
    <div class="layui-col-md12 layadmin-homepage-list-imgtxt message-content sys_show_msg_list001">
{qb:tag name="sys_show_msg_list001" class="app\member\controller\Msg@showmore" union="id" rows="5"}
		<div class="media-body" style="margin-bottom:20px;margin-top:10px;">
          <a href="{:get_url('user',['uid'=>$rs['uid']])}" class="media-left" style="float: left;">
             <img src="{$rs.from_icon}" onerror="this.src='__STATIC__/images/noface.png'" height="46px" width="46px">
          </a>
          <div class="pad-btm">
            <p class="fontColor"><a href="{:get_url('user',['uid'=>$rs['uid']])}">{$rs.from_username}</a></p>
            <p class="min-font">
              {$rs.create_time}
            </p>         
         </div>
          <p class='msg_title'>{$rs.title}</p>
          <p class="message-text">{$rs.content}</p>
       </div>
{/qb:tag}
    </div>
  </div>
</div>


<script type="text/javascript">
function postmsg(){
	var url = "{:urls('wxapp.msg/add')}";
	var content = $(".msgcontent").val();
	if(content==''){
		layer.alert('消息内容不能为空');
		return ;
	}
	$.post(url,{'uid':"{$info.uid}",'content':content,},function(res){		
		if(res.code==0){
			layer.msg('发送成功');
			setTimeout(function(){
				window.location.href = "{:urls('index')}";
			},500);
		    //$(".msglist").html( make_html(res.data) );
		}else{
			layer.alert('发送失败:'+res.msg);
		}
	});
}

var msg_page=1;
function showMoreMsg(){
  var url = "{qb:url name='sys_show_msg_list001' /}";
  msg_page++;
  $.get(url+msg_page,function(res){  
    console.log(res);
    console.log(res.data);
    if(res.code==0){
      if(res.data==''){
        layer.msg("已经显示完了！",{time:500});
      }else{
        $('.sys_show_msg_list001').append(res.data);
        scroll_get = true;
      }
    }else{
      layer.msg(res.msg,{time:2500});
    }
  });
}


//滚动显示更多
var scroll_get = true;  //做个标志,不要反反复复的加载
$(document).ready(function () {
  $(window).scroll(function () {
    if (scroll_get==true &&  (400 + $(window).scrollTop())>($(document).height() - $(window).height())) {
      scroll_get = false;     
      layer.msg('内容加截中,请稍候',{time:1500});
      showMoreMsg();
    }
  });
});
</script>

{/block}